package com.matrix.geo.playmysqlgeo.config;

import com.fasterxml.jackson.databind.module.SimpleModule;
import com.matrix.geo.playmysqlgeo.serializers.*;
import org.locationtech.jts.geom.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JtsJacksonConfig {

    @Bean
    public SimpleModule jtsGeometrySimpleModule() {
        return new SimpleModule()
                .addSerializer(Geometry.class, new GeometryJacksonSerializer())
                .addDeserializer(Geometry.class, new GeometryJacksonDeserializer())
                .addDeserializer(Point.class, new PointJacksonDeserializer())
                .addDeserializer(Point.class, new PointJacksonDeserializer())
                .addDeserializer(LineString.class, new LineStringJacksonDeserializer())
                .addDeserializer(LinearRing.class, new LinearRingJacksonDeserializer())
                .addDeserializer(Polygon.class, new PolygonJacksonDeserializer())
                .addDeserializer(MultiPoint.class, new MultiPointJacksonDeserializer())
                .addDeserializer(MultiLineString.class, new MultiLineStringJacksonDeserializer())
                .addDeserializer(MultiPolygon.class, new MultiPolygonJacksonDeserializer())
                .addDeserializer(GeometryCollection.class, new GeometryCollectionJacksonDeserializer());
    }

}
